import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:haokezufang/pages/details/room_details.dart';
import 'package:haokezufang/pages/home/index.dart';
import 'package:haokezufang/pages/login.dart';
import 'package:haokezufang/pages/not_found.dart';
import 'package:haokezufang/pages/register.dart';
import 'package:haokezufang/pages/room_manager/room_add/index.dart';
import 'package:haokezufang/pages/room_manager/room_manager.dart';
import 'package:haokezufang/pages/splash.dart';

import 'pages/settings.dart';

/// fluro路由
class Routes {
  // 路由管理
  static FluroRouter? router;

  static String home = "/";
  static String login = "/login";
  static String register = "/register";
  static String roomdetail = "/roomdetail/:roomId";
  static String settings = "/settings";
  static String roomManager = "/roomManager";
  static String roomAdd = "/roomAdd";
  static String splash = "/splash";

  static final _homeHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const HomePage();
  });

  static final _loginHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const LoginPage();
  });
  static final _registerHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const RegisterPage();
  });
  static final _settingsHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const SettingPage();
  });
  static final _roomManagerHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const ManagerRoom();
  });
  static final _roomAddHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const RoomAdd();
  });
  static final _splashHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const SplashPage();
  });
  static final _roomdetailHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return RoomDetailPage(
      roomId: params['roomId']![0],
    );
  });
  static void configureRoutes(FluroRouter router) {
    router.notFoundHandler = Handler(
        handlerFunc: (BuildContext? context, Map<String, dynamic> params) {
      return const NotFoundPage();
    });
    router.define(home, handler: _homeHandler);
    router.define(login, handler: _loginHandler);
    router.define(register, handler: _registerHandler);
    router.define(roomdetail, handler: _roomdetailHandler);
    router.define(settings, handler: _settingsHandler);
    router.define(roomAdd, handler: _roomAddHandler);
    router.define(splash, handler: _splashHandler);
    router.define(roomManager, handler: _roomManagerHandler);
  }
}
